package api

import (
	"api-gatway/basic/config"
	__ "api-gatway/basic/proto"
	"api-gatway/handler/request"
	"github.com/gin-gonic/gin"
)

func Upload(c *gin.Context) {
	var err error
	var form request.Uplo

	// 根据 Content-Type Header 推断使用哪个绑定器。
	if err = c.ShouldBind(&form); err != nil {
		c.JSON(400, gin.H{
			"message": "参数有误",
			"code":    "400",
		})
		return
	}

	// 用户名是否存在，需要调用 user 服务
	_, err = config.VideoClient.VideoUpload(c, &__.VideoUploadReq{
		File: form.File,
	})

	if err != nil {
		c.JSON(500, gin.H{
			"message": "服务异常",
			"code":    "500",
		})
		return
	}
	// 调用 user 服务创建用户

	c.JSON(200, gin.H{
		"message": "上传成功",
		"code":    "200",
	})

	return
}
